#!/bin/bash

cd /
image=$1

PTFNUM=U498694
v1=`/opt/hsc/bin/hsc version | grep Version | cut -f3 -d" "`
v2=`/opt/hsc/bin/hsc version | grep Release | cut -f3 -d" "`
vers=`echo $v1.$v2`

if [ $vers != "3.3.0" ]; then
   echo "Incompatible Update. Updates not installed"
   exit 2
fi

if [ -f $image/hsc.tar ]
then
   echo "--- Installing updates..." |tee -a  $logFile
   cd /
   tar -xf $image/hsc.tar
   if [ $? -ne 0 ]
   then
      exit 6
   fi
   chmod 555 opt/hsc/bin/getRemoteFrameFiles
   chown bin:bin opt/hsc/bin/getRemoteFrameFiles
   tar -tf $image/hsc.tar | sed -e 's/^.//' > /opt/hsc/data/extbackupfile.list
fi

echo "PLEASE REBOOT YOUR SYSTEM IN ORDER TO COMMIT THE CHANGES....."

PTF=`grep $PTFNUM /opt/hsc/data/version`
if [ "$PTF" = "" ]
then
  echo $PTFNUM >> /opt/hsc/data/version
fi

exit 0
